#include <iostream>
#include "MyPthread/Thread.hpp"
#include "MyPthread/Log.hpp"
#include "MyPthread/Cond.hpp"
#include "MyPthread/Mutex.hpp"
#include <unistd.h>
#include <vector>
#include <time.h>
#include <sys/types.h>

using namespace ThreadMoudle;
using namespace LogMoudule;


using task_t = std::function<void()>;

const int N = 20;
Mutex gmtx;
Cond gcond(gmtx.Mutex_ptr());

void task1(std::string name)
{
    while (true)
    {
        /* code */
        LOG(LogLevel::DEBUG)<<"我是线程A";
        gcond.Signal();
        sleep(2);
    }
    
}
void task2(std::string name)
{
    while(true)
    {
        gcond.Wait();
        LOG(LogLevel::DEBUG)<<"我是线程B";
        sleep(2);
    }
}

int main()
{
    ENABLE_CONSOLE_LOG();
    // ENABLE_FILE_LOG();

    Thread a(task1);
    Thread b(task2);
    
    a.Start();
    b.Start();

    a.Join();
    b.Join();



    return 0;
}
